# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Dan McGee <dan@archlinux.org>

pkgname=pgbouncer
pkgver=1.8.1
pkgrel=1
pkgdesc='Lightweight connection pooler for PostgreSQL'
url='https://pgbouncer.github.io/'
arch=('x86_64')
license=('BSD')
depends=('libevent>=2.0' 'c-ares' 'systemd' 'pam')
makedepends=('asciidoc' 'xmlto')
checkdepends=('postgresql-libs')
backup=('etc/pgbouncer/pgbouncer.ini'
        'etc/logrotate.d/pgbouncer')
install=${pkgname}.install
source=(https://pgbouncer.github.io/downloads/files/${pkgver}/pgbouncer-${pkgver}.tar.gz
        pgbouncer.ini
        pgbouncer.logrotate
        pgbouncer.service
        pgbouncer.tmpfiles.conf)
sha256sums=('fa8bde2a2d2c8c80d53a859f8e48bc6713cf127e31c77d8f787bbc1d673e8dc8'
            '4f30e4a3eb76acdd233ebc7dd099dff6976299ba958e40a8429b74112e804b05'
            '8da38746d9c9dfc2433a8cfe22fdaf517e14492672d09e3c48cd4745fc03e9bd'
            '274a3d447c151323f2d297aae881ec69be1477f16e30b0bba469afe68c2d122a'
            '476ea0400ba063e932a58f1f49ae401d65b22add521894872c09ec6985e0960d')

build() {
  cd ${pkgname}-${pkgver}
  ./configure \
    --prefix=/usr \
    --disable-debug \
    --with-pam
  make
}

check() {
  cd ${pkgname}-${pkgver}
  make -C test run_test
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -Dm 644 NEWS.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 COPYRIGHT -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 ../pgbouncer.ini "${pkgdir}/etc/pgbouncer/pgbouncer.ini"
  install -Dm 644 ../pgbouncer.logrotate "${pkgdir}/etc/logrotate.d/pgbouncer"
  install -Dm 644 ../pgbouncer.service "${pkgdir}/usr/lib/systemd/system/pgbouncer.service"
  install -Dm 644 ../pgbouncer.tmpfiles.conf "${pkgdir}/usr/lib/tmpfiles.d/pgbouncer.conf"
  install -d "${pkgdir}/var/log/pgbouncer"
}

# vim: ts=2 sw=2 et:
